<template>
  <custom-navbar
    title="一句话打动hr"
    :auto-back="true"
    left-icon-color="#303133"
  />
  <up-gap height="30rpx" />
  <view class="block-box">
    <view class="mb-20rpx h-[36rpx] text-[26rpx] text-[#1d2129] leading-[40rpx]">
      将作为重要信息展示在HR端首页,请认真填写
    </view>
    <up-textarea v-model="text" placeholder="请输入一句话吸引HR和您进一步沟通,建议20字以内" placeholder-style="font-Size: 24rpx; color:#bebebe;" />
  </view>
  <view>
    <view class="h-190rpx pb-safe" />
    <view
      class="fixed bottom-0 left-0 w-100% flex items-center justify-between bg-#fff px-24rpx pt-24rpx pb-safe"
    >
      <up-button
        :custom-style="{
          background: '#1f50f2',
          color: '#fff',
          height: '82rpx',
          fontSize: '30rpx',
        }"
        shape="circle"
        text="确定"
        @click="submitValue"
      />
    </view>
  </view>
</template>

<script setup lang="ts">
import { ResumeUpdateParams, customerResumeUpdate } from '@/api/user/customer';
import {otherStore} from "@/store";
const text = ref('');
const resumeId = ref(0)
const submitValue = async () => {
  console.log('简历ID：：：', resumeId.value)
  if (resumeId.value == 0) {
    uni.showToast({title: '简历异常'})
    return
  }
  let params:ResumeUpdateParams = {
    id: resumeId.value,
    heart_content: text.value
  }
  console.log('参数：：：', params)
  let r = await customerResumeUpdate(params)
  if (r) {
    otherStore().setOneSpeak(text.value)
    uni.navigateBack()
    // uni.redirectTo({
    //   url: '/pages/userinfo/resume-create?resume_id=' + resumeId.value
    // })
  } else {
    uni.showToast({
      title: '打动HR 更新到简历失败',
      icon: "none"
    })
  }

}
onLoad((query:any) => {
  if (query.resumeId) {
    console.log('打动HR 页获取简历ID', query.resumeId)
    resumeId.value = query.resumeId
  }
})
</script>

<style lang="scss" scoped>
.block-box {
  @apply mx-auto mb-24rpx w-[702rpx] shadow-[0rpx_6rpx_16rpx_0rpx_rgba(191,191,191,0.26)] rounded-[20rpx] bg-#fff p-24rpx;

  &.py-0 {
    padding-top: 0;
    padding-bottom: 0;
  }
}
</style>
